class Foo {
    public void method1() {
        System.out.println("foo 1");
        method2();
    }

    public void method2() {
        System.out.println("foo 2");
    }
}

class Bar extends Foo {
    public void method2() {
        System.out.println("bar 2");
    }

    public void method3() {
        System.out.println("bar 3");
    }
}

class Baz extends Foo {
    public void method1() {
        System.out.println("baz 1");
    }

    public void method2() {
        System.out.println("baz 2");
        method1();
    }
}

class Mumble extends Baz {
    public void method1() {
        super.method1();
        System.out.println("mumble 1");
    }

    public void method3() {
        System.out.println("mumble 3");
    }
}

public class Inheritance3 {
    public static void main(String[] args) {
        Foo var1 = new Bar();
        Foo var2 = new Mumble();
        Bar var3 = new Bar();
        Baz var4 = new Baz();
        Baz var5 = new Mumble();
        Object var6 = new Baz();
        
        var1.method1();
        System.out.println();
        var2.method1();
        System.out.println();
        var3.method1();
        System.out.println();
        var4.method1();
        System.out.println();
        var5.method1();
        System.out.println();
        //var6.method1();
        var1.method2();
        System.out.println();
        var2.method2();
        System.out.println();
        var3.method2();
        System.out.println();
        var4.method2();
        System.out.println();
        var5.method2();
        System.out.println();
        //var6.method2();
        var3.method3();
        System.out.println();
        //var5.method3();
        ((Bar)var1).method3();
        System.out.println();
        //((Mumble)var4).method3();
        ((Mumble)var5).method3();
        System.out.println();
        //((Bar)var2).method3();
        ((Baz)var2).method2();
        System.out.println();
        //((Mumble)var6).method2();
    }
}
